﻿using System;
using System.Reflection;
using Microsoft.Phone.Scheduler;
using Microsoft.Phone.UserData;

namespace Mangopollo.Tasks
{
    public class SaveAppointmentTask
    {
        public AppointmentStatus AppointmentStatus { get; set; }
        //
        // Summary:
        //     Gets or sets the details text that will be set for the new appointment when
        //     the Calendar application is launched.
        //
        // Returns:
        //     The details text for the new appointment.
        public string Details { get; set; }
        //
        // Summary:
        //     Gets or sets the end time for the new appointment when the Calendar application
        //     is launched.
        //
        // Returns:
        //     The end time for the new appointment.
        public DateTime? EndTime { get; set; }
        //
        // Summary:
        //     Gets or sets the whether the new appointment shown when the Calendar application
        //     is launched is an all day event.
        //
        // Returns:
        //     Whether the new appointment is an all day event.
        public bool IsAllDayEvent { get; set; }
        //
        // Summary:
        //     Gets or sets the location string that will be set for the new appointment
        //     when the Calendar application is launched.
        //
        // Returns:
        //     The location string of the new appointment.
        public string Location { get; set; }
        //
        // Summary:
        //     Gets or sets the reminder time that will be set for the new appointment when
        //     the Calendar application is launched.
        //
        // Returns:
        //     The reminder time for the new appointment.
        public Reminder Reminder { get; set; }
        //
        // Summary:
        //     Gets or sets the start time that will be set for the new appointment when
        //     the Calendar application is launched.
        //
        // Returns:
        //     The start time for the new appointment.
        public DateTime? StartTime { get; set; }
        //
        // Summary:
        //     Gets or sets the subject that will be set for the new appointment when the
        //     Calendar application is launched.
        //
        // Returns:
        //     The subject for the new appointment.
        public string Subject { get; set; }


        public void Show()
        {
            Type taskDataType = Type.GetType("Microsoft.Phone.Tasks.SaveAppointmentTask, Microsoft.Phone");
            object task = taskDataType.GetConstructor(new Type[] {}).Invoke(null);
            Utils.SetProperty(task, "Details", Details);
            Utils.SetProperty(task, "EndTime", EndTime);
            Utils.SetProperty(task, "IsAllDayEvent", IsAllDayEvent);
            Utils.SetProperty(task, "Location", Location);
            Utils.SetProperty(task, "Reminder", Reminder);
            Utils.SetProperty(task, "StartTime", StartTime);
            Utils.SetProperty(task, "Subject", Subject);
            MethodInfo showmethod = taskDataType.GetMethod("Show");
            showmethod.Invoke(task, new object[] {});
        }
    }
}